<!-- right-->
  <div class="MemberMain">
  <div>

<div class="title"><span style="float:left"><{t}>收货地址<{/t}><span class="disc">|</span> <span id='add' class="disc add_icon" ><a href="javascript:void(0);" style="margin-left:6px"><{t}>添加新的收货地址<{/t}></a></span></span><{if !$is_allow}><span class="noticebox"><{t}>最多只能添加5个地址，请先删除一条地址之后再添加<{/t}></span><{/if}></div>

<{if !$receiver}>
<div class="noinfo"><{t}>暂无收货地址<{/t}></div>
<{/if}>
<!--<span><a href="<{link app=b2c ctl='site_member' act='add_receiver'}>" class="lnk"><img src="<{$res_url}>/btn-addaddress.gif" /></a></span>
-->
<{if $is_allow}>
<div id='addr_div' style="display:none">
<form method="post" action="<{link app=b2c ctl='site_member' act='insert_rec'}>">
<div class="division" style="border:none; border-bottom:1px dashed #ddd">
<table cellpadding="0" class="forform" cellspacing="0" border="0">
<tr>
<th><{t}>收货人：<{/t}></th><td><{input class="inputstyle" name="name" type="text" required="true" id="name" size="30" vtype="required" value=$name|escape:'html'}></td></tr>
<tr><th><{t}>地区：<{/t}></th><td><span id="checkout-select-area"><{input type="region" name="area" required="true" value='' app="ectools"}></span></td></tr>
<tr><th><{t}>地址：<{/t}></th><td><{input class="inputstyle" type="textarea"  name="addr" id="addr"  rows="2" cols="30" value=$addr|escape:'html'}></td></tr>
<tr><th><{t}>邮编：<{/t}></th><td><{input class="inputstyle" name="zipcode" size="15" required="true" value=$zipcode vtype="required&&number"}></td></tr>
<tr><th><{t}>手机：<{/t}></th><td><{input class="inputstyle"  name="phone[mobile]" vtype="number" id="mobile" size="15" value=$mobile|escape:'html'}>&nbsp;<{t}>或固定电话<{/t}>&nbsp;<{input class="inputstyle" name="phone[telephone]" type="order_tel" size="15" value=$tel}></td>
<td style="padding:8px 0 0 0"><input type="hidden" vtype="mobile_or_phone" /></td>
</tr>
</table>
</div>
<div style="padding-left:142px; "><span class="float_span" >
<button  class="btn dicusbtn " type="submit"> <span><span> <{t}>保存<{/t}></span></span> </button></span>
<span class="float_span" style="float:left; margin-left:8px">
<button  id="unset" class="btn dicusbtn " type="button"> <span><span> <{t}>取消添加<{/t}></span></span> </button></span>
</div>
</form>
</div>
<{/if}>
<table class="gridlist" width="100%" border="0" cellspacing="0" style="margin-top:12px" cellpadding="0">
    <tr>
        <th><{t}>地址<{/t}></th>
        <th><{t}>收货人<{/t}></th>
        <th><{t}>联系电话<{/t}></th>
        <th><{t}>默认<{/t}></th>
        <th><{t}>操作<{/t}></th>
    </tr>
   
    <tbody>
    <{foreach from=$receiver item=items key=key}>
    <tr>
    <td class="textwrap" style="text-align:left;"><{$items.area|region}> <{$items.addr|escape:'html'}> , <{$items.zip|escape:'html'}></td>
<td><a href="<{link app=b2c ctl='site_member' act='modify_receiver' arg0=$items.addr_id}>"><{$items.name|escape:'html'}></a></td>
      <td><{$items.mobile|escape:'html'}></td>
      <td><{if $items.def_addr}>
          <span class="set-tacitly"><a href='<{link app=b2c ctl=site_member act=set_default arg0=$items.addr_id arg1=1}>'><{t}>取消默认<{/t}></a></span>
          <{else}>
          <span class="tacitly-add"><a href='<{link app=b2c ctl=site_member act=set_default arg0=$items.addr_id arg1=2}>'><{t}>设为默认<{/t}></a></span>
          <{/if}>
      </td>
      <td align="center"><a href="#" onclick="a('<{link app=b2c ctl=site_member act=modify_receiver arg0=$items.addr_id}>');"><{t}>修改<{/t}></a><br /><a class="delete_addr" href="<{link app=b2c ctl=site_member act=del_rec arg0=$items.addr_id}>" ><{t}>删除<{/t}></a></td>
    </tr>
    <{/foreach}>
    </tbody>
 
</table>


</div>
</div>

<script>
function a(url,options){
    
   options = $extend({
     width:window.getSize().x*0.8,
     height:window.getSize().y*0.8
   },options||{});
   var params = 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width={width},height={height}';
   params = params.substitute(options);

   window.open(url||'about:blank','_blank',params);
}

</script>

<script>
(function(){
    
    $$(".delete_addr").addEvent('click',function(e){
         if(!confirm('<{t}>确定删除?<{/t}>'))return false;
    });
    $("add").addEvent('click',function(e){
        if(<{$is_allow}>)
        {
            $('addr_div').setStyle('display','inline');
        }
        else{
            return false;
        }
    });
    
	<{if $is_allow}>
	$E('#checkout-select-area input[name=area').store('lastsel',function(lastselect){
        var areaSels=$ES("#checkout-select-area select");
        var areaSelPrt=areaSels[0].getParent('*[package=mainland]');
        var selected=[];
        areaSels.each(function(s){
           var text = s[s.selectedIndex].text.trim().clean();
           if(['<{t}>北京<{/t}>','<{t}>天津<{/t}>','<{t}>上海<{/t}>','<{t}>重庆<{/t}>'].indexOf(text)>-1)return;
           selected.push(text);
        });
        var selectedV = selected.join('');
        $('addr').value = selectedV;
    });
	
    validatorMap.set('mobile_or_phone', ['<{t}>手机或电话必填其一！<{/t}>', function(element, v) {
		var _contacts = $(element).getParent('td').getPrevious('td').getElements('input');
		
		var _is_validate = false;
		_contacts.each(function(el){
			if (el.value) _is_validate = true||_is_validate;
		});
		
		return _is_validate;
	}]);
	
	$("unset").addEvent('click',function(e){
            $('addr_div').setStyle('display','none');
    });
	<{/if}>
})();
</script>

<!-- right-->
